package com.zykj.spb.study.controller;

import com.zykj.spb.study.entity.properties.Person;
import com.zykj.spb.study.entity.user.User;
import com.zykj.spb.study.service.user.IUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author zhoulj(周利军) [1217102780@qq.com]
 * @Title: PersonController
 * @Project: ${MODEL_NAME}
 * @Module ID:   <(模块)类编号，可以引用系统设计中的类编号>
 * @Comments: <对此类的描述，可以引用系统设计中的描述>
 * @JDK version used:      <JDK1.8> 37
 * @since 2018/12/18-14:37
 */
@Controller
@RequestMapping("person")
public class PersonController {
    Logger logger = LoggerFactory.getLogger(PersonController.class);


    private Person person;
    @Autowired
    private IUserService userService;

    //TODO 这是Spring 4x 推荐的方式， 采用构造器的方式注入
    @Autowired
    public PersonController(Person person) {
        this.person = person;
    }

    @RequestMapping("index")
    @ResponseBody
    public String index() {
        logger.debug("【PersonController】index 方法进入... ");
        return person.toString();
    }

    @RequestMapping("cache")
    @ResponseBody
    public String cache() {
        logger.debug("【测试缓存】cache 方法进入... ");
        User user = userService.getById(16);
        logger.debug(user.getNickName());
        return "cache";
    }
}
